<!DOCTYPE html>
<html lang="en" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<!--这里是导入的命名空间-->
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
<div style="text-align: center">

    <div sec:authorize="!isAuthenticated()">
        <a th:href="@{/toLogin}">登录</a>
        <!--上面的这个sec就是用来判断用户是否登录的了-->
    </div>
    <div sec:authorize="isAuthenticated()">
        <!--<a th:href="@{/logout}">注销</a>-->
        <!--这种注销方式不是太安全-->
        <form method="post" th:action="@{/logout}">
            <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
            <input type="submit" value="注销">
        </form>
    </div>

    <h1>欢迎来到首页</h1>
    <table>
        <tr>
            <th>leve1</th>
            <th>leve2</th>
            <th>leve3</th>
        </tr>
        <tr>
            <td><a href="/level1/1">1-1</a></td>
            <td><a href="/level2/1">2-1</a></td>
            <td><a href="/level3/1">3-1</a></td>
        </tr>
        <tr>
            <td><a href="/level1/2">1-2</a></td>
            <td><a href="/level2/2">2-2</a></td>
            <td><a href="/level3/2">3-2</a></td>
        </tr>
        <tr>
            <td><a href="/level1/3">1-3</a></td>
            <td><a href="/level2/3">2-3</a></td>
            <td><a href="/level3/3">3-3</a></td>
        </tr>
    </table>
</div>
</body>
</html>